package com.qf.smsplatfrom.controller;

import com.qf.smsplatfrom.dto.R;
import com.qf.smsplatfrom.dto.UserDto;
import com.qf.smsplatfrom.pojo.TAdminUser;
import com.qf.smsplatfrom.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;

@RestController
@RequestMapping("/user")
@SessionAttributes({"user"})
public class UserController {
    private UserService userService;
    @Autowired
    public void setUserService(UserService userService) {
        this.userService = userService;
    }
    @PostMapping("/login")
    public R login(@RequestBody UserDto userDto, HttpSession session,Model model){

        TAdminUser tAdminUser = userService.showByLogin(userDto);
        model.addAttribute("user",tAdminUser);
        //session.setAttribute("user",tAdminUser);
        return R.setOk();
    }
}
